<template>
    <view class="content">
        <view class="item" v-for="(item, index) in list" :key="index" @click="choose(item)">
            <view class="u-flex u-row-between u-col-center">
                <view class="title">{{item.items}}</view>
                <view class="status" v-if="item.status == 3">服务中</view>
                <view class="status" v-if="item.status == 4">已完成</view>
            </view>
            <view class="time">{{item.week}}</view>
            <view class="item-down">
                <image :src="IMAGEURL + 'static/icon/icon_01.png'" class="icon-01"></image>
                <view class="name">{{item.name}}</view>
                <view class="male" v-if="item.gender == 1">男</view>
                <view class="female" v-if="item.gender == 2">女</view>
                <view class="age">{{item.age}}岁</view>
            </view>
        </view>
        
        <view style="height: 94rpx;padding-top: 30rpx;">
            <u-loadmore :status="status" v-if="status != 'loadmore'" />
        </view>
    </view>
</template>

<script>
    import { IMAGEURL } from '@/static/js/common.js';
    export default {
        data() {
            return {
                IMAGEURL,
                status: 'loadmore', //是否显示没有更多了
                page: 1,
                list: [],
            };
        },
        onLoad() {
            this.getList()
        },
        onReachBottom() {
        	if(this.page == 1){return}
        	this.getList()
        },
        methods: {
            choose(item) {
                uni.$emit('CHOOSE_ORDER', item)
                this.$backT()
            },
            
            getList() {
            	if (this.status == 'nomore') return;
            	this.status = 'loading';
            	this.$ajax('order_list', {
            		user_token: this.$getSync('userToken'),
            		page: this.page,
            		limit: 10,
                    type: 4,//类型 1全部订单 2周期服务 3服务人员首页 4报销选择订单
                    status: '',//1未支付 2待接单 3服务中 4已完成
            	}).then(ret => {
            		if (ret.success == 1000) {
            			if (ret.detail && ret.detail.orders && ret.detail.orders.length > 0) {
            				this.list = this.list.concat(ret.detail.orders);
            				this.page++;
            				this.status = 'loadmore'
            			} else {
            				this.status = 'nomore'
            			}
            		} else {
            			this.$toast(ret.msg);
            		}
            	});
            },
        }
    };
</script>

<style lang="scss">
    page{
        background-color: #f5f5f5;
    }
    .content{
        padding: 20rpx;
    }
    
    .item{
        padding: 35rpx 25rpx;
        margin-bottom: 20rpx;
        background-color: #fff;
        border-radius: 15rpx;
    }
    .title{
        flex: 1;
        font-size: 34rpx;
        font-weight: bold;
        word-break: break-all;
        white-space: pre-line;
    }
    .status{
        font-size: 24rpx;
        color: #fec427;
        padding-left: 15rpx;
    }
    .time{
        font-size: 26rpx;
        color: #8e8e8e;
        padding-top: 10rpx;
    }
    .item-down{
        display: flex;
        justify-content: flex-start;
        align-items: center;
        padding-top: 20rpx;
    }
    .icon-01{
        width: 37rpx;
        height: 37rpx;
        margin-right: 15rpx;
    }
    .name{
        font-size: 32rpx;
        font-weight: bold;
        padding-right: 15rpx;
    }
    .male{
        width: 34rpx;
        height: 34rpx;
        border-radius: 5rpx;
        background-color: #edf6ff;
        font-size: 26rpx;
        color: #2d96fa;
        text-align: center;
        line-height: 34rpx;
    }
    .female{
        width: 34rpx;
        height: 34rpx;
        border-radius: 5rpx;
        background-color: #ffeeed;
        font-size: 26rpx;
        color: #ff5748;
        text-align: center;
        line-height: 34rpx;
    }
    .age{
        font-size: 26rpx;
        color: #727272;
        padding-left: 15rpx;
    }

</style>
